<?php
declare (strict_types = 1);

namespace app\adminapi\model\system\auth;

use adminmatrix\server\app\model\BaseModel;
use think\Model;
use think\model\relation\HasMany;

/**
 * @mixin \think\Model
 */
class Role extends BaseModel
{
    protected $name = 'admin_role';
    protected array $type = [
        'status'    =>  'bool'
    ];
    #-------------------------------------------------------------------
    # 模型事件
    #-------------------------------------------------------------------
    public static function onBeforeDelete(Model $model): void
    {
        $model->role()->delete();
//        parent::onBeforeDelete($model); // TODO: Change the autogenerated stub
    }



    #-------------------------------------------------------------------
    # 关联表
    #-------------------------------------------------------------------

    /**
     * 角色关联权限
     * @return HasMany
     */
    public function role() : HasMany
    {
        return $this->hasMany(AdminRolePermission::class ,'role_id'  );
    }
}
